package io.chance.receiverlei.channel;

import io.chance.receiverlei.main.AppStart;
import lrq.common.MyLog;
import org.apache.log4j.Logger;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;

/**
 * 通道打开处理器
 * @author gislin
 *
 */
public class ChannelOpenHandle extends SimpleChannelUpstreamHandler {

	static Logger connectLog = null;
	
	@Override
	public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
		if(connectLog == null){
			connectLog = MyLog.getLogger(AppStart.connectLogName);
		}
		ChannelManager.addDevice(null,e.getChannel());
		super.channelOpen(ctx, e);
		connectLog.info("地址："+e.getChannel().getRemoteAddress()+",ID:"+ChannelManager.getChannelId(e.getChannel())+",打开");
	}
}
